package net.office.service.impl;

import net.office.bean.StaffResume;
import net.office.bean.StaffResumeExample;
import net.office.bean.StaffTrainExample;
import net.office.mapper.StaffResumeMapper;
import net.office.service.StaffResumeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StaffResumeServiceImpl implements StaffResumeService {

    @Autowired
    private StaffResumeMapper staffResumeMapper;

    @Override
    public List<StaffResume> findAll() {
        StaffResumeExample example = new StaffResumeExample();
        return staffResumeMapper.selectByExample(example);
    }

    @Override
    public int deleteByPrimaryKey(Integer staffResumeId) {
        return staffResumeMapper.deleteByPrimaryKey(staffResumeId);
    }

    @Override
    public List<StaffResume> findByStaffResume(StaffResume staffResume) {
        StaffResumeExample example = new StaffResumeExample();
        StaffResumeExample.Criteria criteria = example.createCriteria();

        if(staffResume.getStaffResumeId() != null){
            criteria.andStaffResumeIdEqualTo(staffResume.getStaffResumeId());
        }
        if(staffResume.getStaffResumeName() != null
                && staffResume.getStaffResumeName().trim().length() != 0){
            criteria.andStaffResumeNameLike("%" + staffResume.getStaffResumeName() + "%");
        }
        if(staffResume.getStaffResumeSex() != null){
            criteria.andStaffResumeSexEqualTo(staffResume.getStaffResumeSex());
        }
        if(staffResume.getStaffResumeBirthday() != null){
            criteria.andStaffResumeBirthdayEqualTo(staffResume.getStaffResumeBirthday());
        }
        if(staffResume.getStaffResumePolicy() != null){
            criteria.andStaffResumePolicyEqualTo(staffResume.getStaffResumePolicy());
        }
        if(staffResume.getStaffResumeNation() != null){
            criteria.andStaffResumeNationEqualTo(staffResume.getStaffResumeNation());
        }
        if(staffResume.getStaffResumePhone() != null
                && staffResume.getStaffResumePhone().trim().length() != 0){
            criteria.andStaffResumePhoneLike("%" + staffResume.getStaffResumePhone() + "%");
        }
        if(staffResume.getStaffResumeEmail() != null
                && staffResume.getStaffResumeEmail().trim().length() != 0){
            criteria.andStaffResumeEmailLike("%" + staffResume.getStaffResumeEmail() + "%");
        }
        if(staffResume.getStaffResumeEdu() != null){
            criteria.andStaffResumeEduEqualTo(staffResume.getStaffResumeEdu());
        }
        if(staffResume.getStaffResumeEmail() != null
                && staffResume.getStaffResumeEmail().trim().length() != 0){
            criteria.andStaffResumeEmailLike("%" + staffResume.getStaffResumeEmail() + "%");
        }
        if(staffResume.getStaffResumeEduBg() != null
                && staffResume.getStaffResumeEduBg().trim().length() != 0){
            criteria.andStaffResumeEduBgLike("%" + staffResume.getStaffResumeEduBg() + "%");
        }
        if(staffResume.getStaffResumeWorkBg() != null
                && staffResume.getStaffResumeWorkBg().trim().length() != 0){
            criteria.andStaffResumeWorkBgLike("%" + staffResume.getStaffResumeWorkBg() + "%");
        }
        if(staffResume.getStaffResumeSkillList() != null
                && staffResume.getStaffResumeWorkBg().trim().length() != 0){
            criteria.andStaffResumeSkillListLike("%" + staffResume.getStaffResumeSkillList() + "%");
        }
        if(staffResume.getStaffResumeSelfIntroduce() != null
                && staffResume.getStaffResumeSelfIntroduce().trim().length() != 0){
            criteria.andStaffResumeSelfIntroduceLike("%" + staffResume.getStaffResumeSelfIntroduce() + "%");
        }
        if(staffResume.getStaffResumeResult() != null){
            criteria.andStaffResumeResultEqualTo(staffResume.getStaffResumeResult());
        }
        example.or(criteria);

        return staffResumeMapper.selectByExample(example);
    }

    @Override
    public int insert(StaffResume staffResume) {
        return staffResumeMapper.insertSelective(staffResume);
    }

    @Override
    public StaffResume findOneByStaffResumeId(Integer staffResumeId) {
        return null;
    }

    @Override
    public int updateByPrimaryKey(StaffResume staffResume) {
        return 0;
    }

    @Override
    public List<StaffResume> findAllByStaffId(int staffId) {
        return null;
    }
}
